﻿namespace Jsl.FxCop
{
    using System.Diagnostics;
    using Microsoft.FxCop.Sdk;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    public static class ProblemAssert
    {
        /// <summary>
        /// Asserts that the problems has the expected values.
        /// </summary>
        /// <param name="problem">The problem.</param>
        /// <param name="certainty">The certainty.</param>
        /// <param name="fixCategory">The fix category.</param>
        /// <param name="messageLevel">The message level.</param>
        /// <param name="resolution">The resolution.</param>
        [DebuggerHidden]
        public static void That(this Problem problem, int certainty, FixCategories fixCategory, MessageLevel messageLevel, string resolution)
        {
            AssertEx.That(() => problem.Certainty == certainty);
            AssertEx.That(() => problem.FixCategory == fixCategory);
            AssertEx.That(() => problem.MessageLevel == messageLevel);
            AssertEx.That(() => problem.Resolution.ToString() == resolution);
        }

        /// <summary>
        /// Asserts that there are no problems.
        /// </summary>
        /// <param name="problems">The problems.</param>
        [DebuggerHidden]
        public static void That(this ProblemCollection problems)
        {
            AssertEx.That(() => problems.Count == 0);
        }

        /// <summary>
        /// Asserts that there is only one problem and that it has the expected values.
        /// </summary>
        /// <param name="problems">The problems.</param>
        /// <param name="certainty">The certainty.</param>
        /// <param name="fixCategory">The fix category.</param>
        /// <param name="messageLevel">The message level.</param>
        /// <param name="resolution">The resolution.</param>
        [DebuggerHidden]
        public static void That(this ProblemCollection problems, int certainty, FixCategories fixCategory, MessageLevel messageLevel, string resolution)
        {
            AssertEx.That(() => problems.Count == 1);
            ProblemAssert.That(problems[0], certainty, fixCategory, messageLevel, resolution);
        }
    }
}